package MyHashMap;

import java.security.Permission;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;



import until.CommRes;



//Thread绫绘瀯閫犳柟娉曪細
//1.Thread锛堬級锛�
//2.Thread锛圫tring name锛夛紱
//3.Thread锛圧unable r锛夛紱
//4.Thread锛圧unable r, String name锛夛紱11


//thread绫诲父鐢ㄦ柟娉曪細
//start();//鍚姩绾跨▼
//getId();//鑾峰緱绾跨▼ID
//getName();//鑾峰緱绾跨▼鍚嶅瓧
//getPriority();//鑾峰緱浼樺厛鏉�
//isAlive();//鍒ゆ柇绾跨▼鏄惁娲诲姩
//isDaemon();//鍒ゆ柇鏄惁瀹堟姢绾跨▼
//getState();//鑾峰緱绾跨▼鐘舵��
//sleep(long mill);//浼戠湢绾跨▼
//join();//绛夊緟绾跨▼缁撴潫
//yield();//鏀惧純cpu浣跨敤鏉冨埄
//interrupt();//涓柇绾跨▼
//currentThread();//鑾峰緱姝ｅ湪鎵ц鐨勭嚎绋嬪璞�

//sleep鏄绾跨▼鎸囧畾浼戠湢鏃堕棿锛岀劧鍚庣户缁伐浣�
//wait鍒欐槸绛夊緟锛岀洿鍒版湁绾跨▼閫氱煡notify锛堬級鍞ら啋浠栨墠浼氶噸鏂板伐浣溿��
public class jion extends qwew{/*
		 鏈変笁涓嚎绋婽1 T2 T3锛屽浣曚繚璇佷粬浠寜椤哄簭鎵ц-杞浇
		鍦═2鐨剅un涓紝璋冪敤t1.join锛岃t1鎵ц瀹屾垚鍚庡啀璁㏕2鎵ц
		鍦═2鐨剅un涓紝璋冪敤t2.join锛岃t2鎵ц瀹屾垚鍚庡啀璁㏕3鎵ц
		*/
		   static Thread t1 = new Thread(new Runnable() {

		        @Override
		        public void run() {
		            System.out.println("t11232");
		        }
		    });

		    static Thread t2 = new Thread(new Runnable() {

		        @Override
		        public void run() {
		            try {
//		                t1.join();
		                Thread.sleep(500);
		            } catch (InterruptedException e) {
		                // TODO Auto-generated catch block
		                e.printStackTrace();
		            }
		            System.out.println("t2");
		        }
		    });

		    static Thread t3 = new Thread(new Runnable() {

		        @Override
		        public void run() {
		            try {
//		                t2.join();
		                Thread.sleep(500);
		            } catch (InterruptedException e) {
		                // TODO Auto-generated catch block
		                e.printStackTrace();
		            }
		            System.out.println("t3");
		        }
		    });
		    public static void main(String[] args) throws InterruptedException, ExecutionException {
		    	int i=1;
		    	
		    	while(true)
		    	{ 
		    		List<String> persons =new ArrayList();
		    		persons.add(String.valueOf(i++));
		    		System.out.println(persons.toString());
		    		 Thread.sleep(5);
		    		 
		    		 
		    			List<List> persons2 =new ArrayList();
		    			persons2.add(persons);
			    		System.out.println(persons2.toString());
			    		Thread.sleep(5);
			    		
			    		List<List> persons3 =new ArrayList();
		    			persons3.add(persons2);
			    		System.out.println(persons3.toString());
			    		Thread.sleep(5);
		    		 
		    		 
		    		
		    	}		    	
//			     ExecutorService executor = Executors.newFixedThreadPool(2);
//			   String  str="123";
//							 Future <String> orderDetailFuture = executor.submit(new Callable<String>() {  
//					                @Override  
//					                public String call() throws Exception { 
//					                	return importOrderDetail("11");
//					                }  
//					         }); 
//							    
//							 Future <String> orderDetailFuture2 = executor.submit(new Callable<String>() {  
//					                @Override  
//					                public String call() throws Exception { 
//					                	 return importOrderDetail("12");
//					                }  
//					         }); 
//							 
//							
////						    java 鍒╃敤Future寮傛鑾峰彇澶氱嚎绋嬩换鍔＄粨鏋�
//						    if(orderDetailFuture.get().equals("11") && orderDetailFuture2.get().equals("12")){
//						    	 System.out.println("end");
//						    }
//						    System.out.println("end1");
//						    executor.shutdown();
//						    System.out.println("end2");
						    
//		        t1.start();
//		    	t1.join();
		    	
//		        t2.start();
//		    	t1.join();
//		        t3.start();
//		    	t3.join();
		    	
//		    	1绾跨▼鏌ヨ鏁版嵁鏀惧埌缂撳瓨閲岄潰key锛寁al锛坲uid锛宭ist{1}锛�
//		    	2绾跨▼鏌ヨ鏁版嵁鏀惧埌缂撳瓨閲岄潰list{2}
		    	
//		    	鍋氫釜鐩戞帶锛屽鏋滅紦瀛橀兘鍛戒腑銆傚氨鎷艰浆鏁版嵁
		    	
//		    	锛堬級绾跨▼姹犵殑鏂规硶锛岀敤涓�涓槦鍒楀舰寮忕殑鍗曠嚎绋嬫睜
//		    	4绉嶇嚎绋嬫睜
//		    	ExecutorService 鎻愪緵浜�4绉嶇嚎绋嬫睜锛屽垎鍒槸锛�
//		    	newCachedThreadPool;缂撳瓨绾跨▼姹狅紝鍙伒娲诲洖鏀躲�佹柊寤�
//		    	newFixedThreadPool;瀹氶暱绾跨▼姹狅紝鍙帶鍒舵渶澶у苟鍙戞暟锛岃秴鍑哄湪闃熷垪涓瓑寰�
//		    	newScheduledThreadPool;瀹氶暱绾跨▼姹�,鍙畾鏃躲�佸懆鏈熸墽琛�
//		    	newSingleThreadExecutor;鍗曚竴绾跨▼姹狅紝鎸夐『搴忔墽琛岋紙FIFO,LIFO,浼樺厛绾э級
//		     ExecutorService es = Executors.newSingleThreadExecutor();
//		        es.submit(t1);
//		        es.submit(t2);
//		        es.submit(t3);
//		        es.shutdown();

		    }
		    
		    private static String importOrderDetail(String file) throws InterruptedException{
		    	for(int i=1;i<50;i++){
		    		Thread.sleep(300);//鐫＄湢1绉掋�傚惊鐜�300娆″氨鏄�300绉掍篃灏辨槸浜斿垎閽�
		    		System.out.println(file);
		    	}
		    	 
				return file;
		    
		    }

		
//jion 婧愮爜
public final synchronized void join(long millis)
		  throws InterruptedException {
		      long base = System.currentTimeMillis();
		      long now = 0;
		      if (millis < 0) {
		          throw new IllegalArgumentException("timeout value is negative");
		      }
		      if (millis == 0) {
		          while (isAlive()) {
		              wait(0);
		          }
		      } else {
		          while (isAlive()) {
		              long delay = millis - now;
		              if (delay <= 0) {
		                  break;
		              }
		              wait(delay);
		              now = System.currentTimeMillis() - base;
		          }
		      }
		  }

private boolean isAlive() {
	// TODO Auto-generated method stub
	return false;
}

}